package br.com.timesystem.util;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class JsfUtil {
    
    public static Object recuperarObjetoSessao(String key){
        return getSession().getAttribute(key);	
    }
    
    public static void adicionarObjetoSessao(String key, Object value){
	getSession().setAttribute(key, value);
    }
    
    public static void removerObjetoSessao(String key){
	getSession().removeAttribute(key);
    }
    
    private static HttpSession getSession(){
        FacesContext context = FacesContext.getCurrentInstance();
        ExternalContext externalContext = context.getExternalContext();
        HttpSession session = (HttpSession) externalContext.getSession(true);
	return session;
    }    
    
}
